import React, { useState } from 'react';
import './global.less';
const Person = (props) => {
  //组件通信-父传子： 使用props,父组件把传递的属性,写到子组件标签上,子组件用props接收
  console.log(props);
  const { name, age } = props;
  return (
    <>
      <div className='person-main'>
        <h1>这是子组件</h1>
        <div>我的名字是:{name}</div>
        <div>年龄：{age}</div>
      </div>
    </>
  );
};

export default function CommOne() {
  const [name, setNum] = useState('wdk');
  const [age, setAge] = useState(24);
  return (
    <>
      <div className='comm-main'>
        <h1>这是父组件</h1>
        <Person name={name} age={age} />
      </div>
    </>
  );
}
